FROM harbor.niuguwang.com/commonality/dotnet-core-aspnet:5.0 AS base
WORKDIR /app
EXPOSE 80

FROM harbor.niuguwang.com/commonality/dotnet-core-sdk:5.0 AS build
WORKDIR /src

COPY */*.csproj ./
RUN for file in $(ls *.csproj); do mkdir -p ${file%.*}/ && mv $file ${file%.*}/; done

RUN dotnet restore "HBKY.Shop.AdminAPI/HBKY.Shop.AdminAPI.csproj"
COPY . .

WORKDIR "/src/HBKY.Shop.AdminAPI"
FROM build AS publish
RUN dotnet publish "HBKY.Shop.AdminAPI.csproj" -c Release -o /app/publish

FROM base AS final
RUN rm -f /etc/localtime \
&& ln -sv /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "HBKY.Shop.AdminAPI.dll"]


